#include <stdio.h>

int my_strlen(char *p){
	int count = 0;
#if 0
	while(p[count] != '\0'){
		count++;
	}
#endif

#if 0
	while(*(p+count) != '\0'){
		count++;
	}
#endif

#if 0
	while(*p != '\0'){
		p++;
		count++;
	}
#endif

#if 1
	while(*p++)
		count++;
	// 这种写法 循环结束时 p 指向 '\0' 的后一位
#endif
	return count;
}

int main(int argc, const char *argv[])
{
	char s1[32] = "hello world";
	printf("%d\n", my_strlen(s1)); // 11
	char s2[32] = "hello\0world";
	printf("%d\n", my_strlen(s2)); // 5

	return 0;
}
